﻿package db;
import php.db.ResultSet;

class ItemManager extends php.db.Manager<Item> {
	
	public function new( classval : Class<php.db.Object> ) {
		super(classval);
	}	
	public static function getItem(cat:Array<String>) 
	{	
		var temp = 0;
		var sql = "SELECT DISTINCT i.* FROM categories c, itemtags it, items i WHERE (";
		for (s in cat) {
			sql =  sql +"c.name = '" + s + "' ";
			temp++;
			if (temp < cat.length) sql += "OR ";
		}
		sql = sql + " ) AND c.id=it.id_cat AND it.id_item=i.id;"; 
		return (sql); 
	}
	public static function getLimitItems(id_ch : Int, limit : Int)
	{
		var sql = "SELECT * FROM items WHERE id_ch = " + id_ch +  " LIMIT " + Std.string(limit - 10) + ",10";
		return (sql);
	}
}